#include "findreplacedialog.h"
#include "ui_findreplacedialog.h"
#include <QScreen>

FindReplaceDialog::FindReplaceDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::FindReplaceDialog)
{
    ui->setupUi(this);
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint | Qt::Tool | Qt::WindowTitleHint);
     setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        setWindowTitle("查找替换");



}
FindReplaceDialog::~FindReplaceDialog()
{
    delete ui;
}

void FindReplaceDialog::on_findNextButton_clicked()
{
      emit findRequested(ui->findEdit->text(), getFindFlags());
}

void FindReplaceDialog::on_replaceButton_clicked()
{
      emit replaceRequested(ui->replaceFindEdit->text(), ui->replaceEdit->text(), getFindFlags());
}

void FindReplaceDialog::on_replaceAllButton_clicked()
{
     emit replaceAllRequested(ui->replaceFindEdit->text(), ui->replaceEdit->text(), getFindFlags());
}
void FindReplaceDialog::setCurrentTab(int index) {
    ui->tabWidget->setCurrentIndex(index);
}





QTextDocument::FindFlags FindReplaceDialog::getFindFlags() const {
    QTextDocument::FindFlags flags;
    if (ui->caseCheckBox->isChecked())
        flags |= QTextDocument::FindCaseSensitively;
    if (ui->wholeWordCheckBox->isChecked())
        flags |= QTextDocument::FindWholeWords;
    return flags;
}

